package com.ruoyi.web.controller.platform;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.platform.domain.MWarning;
import com.ruoyi.platform.service.IMWarningService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预警信息Controller
 * 
 * @author dataControl
 * @date 2025-09-15
 */
@RestController
@RequestMapping("/platform/warning")
public class MWarningController extends BaseController
{
    @Autowired
    private IMWarningService mWarningService;

    /**
     * 查询预警信息列表
     */
    @PreAuthorize("@ss.hasPermi('platform:warning:list')")
    @GetMapping("/list")
    public TableDataInfo list(MWarning mWarning)
    {
        startPage();
        List<MWarning> list = mWarningService.selectMWarningList(mWarning);
        return getDataTable(list);
    }

    /**
     * 导出【预警信息】列表
     */
    @PreAuthorize("@ss.hasPermi('platform:warning:export')")
    @Log(title = "导出预警信息列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MWarning mWarning)
    {
        List<MWarning> list = mWarningService.selectMWarningList(mWarning);
        ExcelUtil<MWarning> util = new ExcelUtil<MWarning>(MWarning.class);
        util.exportExcel(response, list, "预警信息数据");
    }

    /**
     * 获取【预警信息】详细信息
     */
    @PreAuthorize("@ss.hasPermi('platform:warning:query')")
    @GetMapping(value = "/{warningId}")
    public AjaxResult getInfo(@PathVariable("warningId") String warningId)
    {
        return success(mWarningService.selectById(warningId));
    }

    /**
     * 修改【预警信息】
     */
    @PreAuthorize("@ss.hasPermi('platform:warning:edit')")
    @Log(title = "预警信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MWarning mWarning)
    {
        return toAjax(mWarningService.updateMWarning(mWarning));
    }

    /**
     * 删除【预警信息】
     */
    @PreAuthorize("@ss.hasPermi('platform:warning:remove')")
    @Log(title = "预警信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warningIds}")
    public AjaxResult remove(@PathVariable String[] warningIds)
    {
        return toAjax(mWarningService.deleteMWarningByWarningIds(warningIds));
    }
}
